package qldc.pm.qlktcsdldc.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.util.PortalUtil;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import qldc.pm.qlktcsdldc.model.DanhMucSoBanNganh_TruongCongDan;
import qldc.pm.qlktcsdldc.model.DanhMucSoBanNganh_TruongCongDanModel;

import java.io.Serializable;

import java.sql.Types;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * The base model implementation for the DanhMucSoBanNganh_TruongCongDan service. Represents a row in the &quot;QLKT_DanhMucSoBanNganh_TruongCongDan&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link qldc.pm.qlktcsdldc.model.DanhMucSoBanNganh_TruongCongDanModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link DanhMucSoBanNganh_TruongCongDanImpl}.
 * </p>
 *
 * @author Brian Wing Shun Chan
 * @see DanhMucSoBanNganh_TruongCongDanImpl
 * @see qldc.pm.qlktcsdldc.model.DanhMucSoBanNganh_TruongCongDan
 * @see qldc.pm.qlktcsdldc.model.DanhMucSoBanNganh_TruongCongDanModel
 * @generated
 */
public class DanhMucSoBanNganh_TruongCongDanModelImpl extends BaseModelImpl<DanhMucSoBanNganh_TruongCongDan>
    implements DanhMucSoBanNganh_TruongCongDanModel {
    /*
     * NOTE FOR DEVELOPERS:
     *
     * Never modify or reference this class directly. All methods that expect a danh muc so ban nganh_ truong cong dan model instance should use the {@link qldc.pm.qlktcsdldc.model.DanhMucSoBanNganh_TruongCongDan} interface instead.
     */
    public static final String TABLE_NAME = "QLKT_DanhMucSoBanNganh_TruongCongDan";
    public static final Object[][] TABLE_COLUMNS = {
            { "IDDanhMucSoBanNganh_TruongCongDan", Types.BIGINT },
            { "groupId", Types.BIGINT },
            { "companyId", Types.BIGINT },
            { "userId", Types.BIGINT },
            { "userName", Types.VARCHAR },
            { "createDate", Types.TIMESTAMP },
            { "modifiedDate", Types.TIMESTAMP },
            { "IDQLKT_DanhMucSoBanNganh", Types.BIGINT },
            { "IDDMDC_TruongCongDan", Types.BIGINT }
        };
    public static final String TABLE_SQL_CREATE = "create table QLKT_DanhMucSoBanNganh_TruongCongDan (IDDanhMucSoBanNganh_TruongCongDan LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,IDQLKT_DanhMucSoBanNganh LONG,IDDMDC_TruongCongDan LONG)";
    public static final String TABLE_SQL_DROP = "drop table QLKT_DanhMucSoBanNganh_TruongCongDan";
    public static final String ORDER_BY_JPQL = " ORDER BY danhMucSoBanNganh_TruongCongDan.IDQLKT_DanhMucSoBanNganh ASC";
    public static final String ORDER_BY_SQL = " ORDER BY QLKT_DanhMucSoBanNganh_TruongCongDan.IDQLKT_DanhMucSoBanNganh ASC";
    public static final String DATA_SOURCE = "liferayDataSource";
    public static final String SESSION_FACTORY = "liferaySessionFactory";
    public static final String TX_MANAGER = "liferayTransactionManager";
    public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.entity.cache.enabled.qldc.pm.qlktcsdldc.model.DanhMucSoBanNganh_TruongCongDan"),
            true);
    public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.finder.cache.enabled.qldc.pm.qlktcsdldc.model.DanhMucSoBanNganh_TruongCongDan"),
            true);
    public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.column.bitmask.enabled.qldc.pm.qlktcsdldc.model.DanhMucSoBanNganh_TruongCongDan"),
            true);
    public static long IDQLKT_DANHMUCSOBANNGANH_COLUMN_BITMASK = 1L;
    public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
                "lock.expiration.time.qldc.pm.qlktcsdldc.model.DanhMucSoBanNganh_TruongCongDan"));
    private static ClassLoader _classLoader = DanhMucSoBanNganh_TruongCongDan.class.getClassLoader();
    private static Class<?>[] _escapedModelInterfaces = new Class[] {
            DanhMucSoBanNganh_TruongCongDan.class
        };
    private long _IDDanhMucSoBanNganh_TruongCongDan;
    private long _groupId;
    private long _companyId;
    private long _userId;
    private String _userUuid;
    private String _userName;
    private Date _createDate;
    private Date _modifiedDate;
    private long _IDQLKT_DanhMucSoBanNganh;
    private long _originalIDQLKT_DanhMucSoBanNganh;
    private boolean _setOriginalIDQLKT_DanhMucSoBanNganh;
    private long _IDDMDC_TruongCongDan;
    private long _columnBitmask;
    private DanhMucSoBanNganh_TruongCongDan _escapedModel;

    public DanhMucSoBanNganh_TruongCongDanModelImpl() {
    }

    @Override
    public long getPrimaryKey() {
        return _IDDanhMucSoBanNganh_TruongCongDan;
    }

    @Override
    public void setPrimaryKey(long primaryKey) {
        setIDDanhMucSoBanNganh_TruongCongDan(primaryKey);
    }

    @Override
    public Serializable getPrimaryKeyObj() {
        return _IDDanhMucSoBanNganh_TruongCongDan;
    }

    @Override
    public void setPrimaryKeyObj(Serializable primaryKeyObj) {
        setPrimaryKey(((Long) primaryKeyObj).longValue());
    }

    @Override
    public Class<?> getModelClass() {
        return DanhMucSoBanNganh_TruongCongDan.class;
    }

    @Override
    public String getModelClassName() {
        return DanhMucSoBanNganh_TruongCongDan.class.getName();
    }

    @Override
    public Map<String, Object> getModelAttributes() {
        Map<String, Object> attributes = new HashMap<String, Object>();

        attributes.put("IDDanhMucSoBanNganh_TruongCongDan",
            getIDDanhMucSoBanNganh_TruongCongDan());
        attributes.put("groupId", getGroupId());
        attributes.put("companyId", getCompanyId());
        attributes.put("userId", getUserId());
        attributes.put("userName", getUserName());
        attributes.put("createDate", getCreateDate());
        attributes.put("modifiedDate", getModifiedDate());
        attributes.put("IDQLKT_DanhMucSoBanNganh", getIDQLKT_DanhMucSoBanNganh());
        attributes.put("IDDMDC_TruongCongDan", getIDDMDC_TruongCongDan());

        return attributes;
    }

    @Override
    public void setModelAttributes(Map<String, Object> attributes) {
        Long IDDanhMucSoBanNganh_TruongCongDan = (Long) attributes.get(
                "IDDanhMucSoBanNganh_TruongCongDan");

        if (IDDanhMucSoBanNganh_TruongCongDan != null) {
            setIDDanhMucSoBanNganh_TruongCongDan(IDDanhMucSoBanNganh_TruongCongDan);
        }

        Long groupId = (Long) attributes.get("groupId");

        if (groupId != null) {
            setGroupId(groupId);
        }

        Long companyId = (Long) attributes.get("companyId");

        if (companyId != null) {
            setCompanyId(companyId);
        }

        Long userId = (Long) attributes.get("userId");

        if (userId != null) {
            setUserId(userId);
        }

        String userName = (String) attributes.get("userName");

        if (userName != null) {
            setUserName(userName);
        }

        Date createDate = (Date) attributes.get("createDate");

        if (createDate != null) {
            setCreateDate(createDate);
        }

        Date modifiedDate = (Date) attributes.get("modifiedDate");

        if (modifiedDate != null) {
            setModifiedDate(modifiedDate);
        }

        Long IDQLKT_DanhMucSoBanNganh = (Long) attributes.get(
                "IDQLKT_DanhMucSoBanNganh");

        if (IDQLKT_DanhMucSoBanNganh != null) {
            setIDQLKT_DanhMucSoBanNganh(IDQLKT_DanhMucSoBanNganh);
        }

        Long IDDMDC_TruongCongDan = (Long) attributes.get(
                "IDDMDC_TruongCongDan");

        if (IDDMDC_TruongCongDan != null) {
            setIDDMDC_TruongCongDan(IDDMDC_TruongCongDan);
        }
    }

    @Override
    public long getIDDanhMucSoBanNganh_TruongCongDan() {
        return _IDDanhMucSoBanNganh_TruongCongDan;
    }

    @Override
    public void setIDDanhMucSoBanNganh_TruongCongDan(
        long IDDanhMucSoBanNganh_TruongCongDan) {
        _IDDanhMucSoBanNganh_TruongCongDan = IDDanhMucSoBanNganh_TruongCongDan;
    }

    @Override
    public long getGroupId() {
        return _groupId;
    }

    @Override
    public void setGroupId(long groupId) {
        _groupId = groupId;
    }

    @Override
    public long getCompanyId() {
        return _companyId;
    }

    @Override
    public void setCompanyId(long companyId) {
        _companyId = companyId;
    }

    @Override
    public long getUserId() {
        return _userId;
    }

    @Override
    public void setUserId(long userId) {
        _userId = userId;
    }

    @Override
    public String getUserUuid() throws SystemException {
        return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
    }

    @Override
    public void setUserUuid(String userUuid) {
        _userUuid = userUuid;
    }

    @Override
    public String getUserName() {
        if (_userName == null) {
            return StringPool.BLANK;
        } else {
            return _userName;
        }
    }

    @Override
    public void setUserName(String userName) {
        _userName = userName;
    }

    @Override
    public Date getCreateDate() {
        return _createDate;
    }

    @Override
    public void setCreateDate(Date createDate) {
        _createDate = createDate;
    }

    @Override
    public Date getModifiedDate() {
        return _modifiedDate;
    }

    @Override
    public void setModifiedDate(Date modifiedDate) {
        _modifiedDate = modifiedDate;
    }

    @Override
    public long getIDQLKT_DanhMucSoBanNganh() {
        return _IDQLKT_DanhMucSoBanNganh;
    }

    @Override
    public void setIDQLKT_DanhMucSoBanNganh(long IDQLKT_DanhMucSoBanNganh) {
        _columnBitmask = -1L;

        if (!_setOriginalIDQLKT_DanhMucSoBanNganh) {
            _setOriginalIDQLKT_DanhMucSoBanNganh = true;

            _originalIDQLKT_DanhMucSoBanNganh = _IDQLKT_DanhMucSoBanNganh;
        }

        _IDQLKT_DanhMucSoBanNganh = IDQLKT_DanhMucSoBanNganh;
    }

    public long getOriginalIDQLKT_DanhMucSoBanNganh() {
        return _originalIDQLKT_DanhMucSoBanNganh;
    }

    @Override
    public long getIDDMDC_TruongCongDan() {
        return _IDDMDC_TruongCongDan;
    }

    @Override
    public void setIDDMDC_TruongCongDan(long IDDMDC_TruongCongDan) {
        _IDDMDC_TruongCongDan = IDDMDC_TruongCongDan;
    }

    public long getColumnBitmask() {
        return _columnBitmask;
    }

    @Override
    public ExpandoBridge getExpandoBridge() {
        return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
            DanhMucSoBanNganh_TruongCongDan.class.getName(), getPrimaryKey());
    }

    @Override
    public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
        ExpandoBridge expandoBridge = getExpandoBridge();

        expandoBridge.setAttributes(serviceContext);
    }

    @Override
    public DanhMucSoBanNganh_TruongCongDan toEscapedModel() {
        if (_escapedModel == null) {
            _escapedModel = (DanhMucSoBanNganh_TruongCongDan) ProxyUtil.newProxyInstance(_classLoader,
                    _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
        }

        return _escapedModel;
    }

    @Override
    public Object clone() {
        DanhMucSoBanNganh_TruongCongDanImpl danhMucSoBanNganh_TruongCongDanImpl = new DanhMucSoBanNganh_TruongCongDanImpl();

        danhMucSoBanNganh_TruongCongDanImpl.setIDDanhMucSoBanNganh_TruongCongDan(getIDDanhMucSoBanNganh_TruongCongDan());
        danhMucSoBanNganh_TruongCongDanImpl.setGroupId(getGroupId());
        danhMucSoBanNganh_TruongCongDanImpl.setCompanyId(getCompanyId());
        danhMucSoBanNganh_TruongCongDanImpl.setUserId(getUserId());
        danhMucSoBanNganh_TruongCongDanImpl.setUserName(getUserName());
        danhMucSoBanNganh_TruongCongDanImpl.setCreateDate(getCreateDate());
        danhMucSoBanNganh_TruongCongDanImpl.setModifiedDate(getModifiedDate());
        danhMucSoBanNganh_TruongCongDanImpl.setIDQLKT_DanhMucSoBanNganh(getIDQLKT_DanhMucSoBanNganh());
        danhMucSoBanNganh_TruongCongDanImpl.setIDDMDC_TruongCongDan(getIDDMDC_TruongCongDan());

        danhMucSoBanNganh_TruongCongDanImpl.resetOriginalValues();

        return danhMucSoBanNganh_TruongCongDanImpl;
    }

    @Override
    public int compareTo(
        DanhMucSoBanNganh_TruongCongDan danhMucSoBanNganh_TruongCongDan) {
        int value = 0;

        if (getIDQLKT_DanhMucSoBanNganh() < danhMucSoBanNganh_TruongCongDan.getIDQLKT_DanhMucSoBanNganh()) {
            value = -1;
        } else if (getIDQLKT_DanhMucSoBanNganh() > danhMucSoBanNganh_TruongCongDan.getIDQLKT_DanhMucSoBanNganh()) {
            value = 1;
        } else {
            value = 0;
        }

        if (value != 0) {
            return value;
        }

        return 0;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }

        if (!(obj instanceof DanhMucSoBanNganh_TruongCongDan)) {
            return false;
        }

        DanhMucSoBanNganh_TruongCongDan danhMucSoBanNganh_TruongCongDan = (DanhMucSoBanNganh_TruongCongDan) obj;

        long primaryKey = danhMucSoBanNganh_TruongCongDan.getPrimaryKey();

        if (getPrimaryKey() == primaryKey) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        return (int) getPrimaryKey();
    }

    @Override
    public void resetOriginalValues() {
        DanhMucSoBanNganh_TruongCongDanModelImpl danhMucSoBanNganh_TruongCongDanModelImpl =
            this;

        danhMucSoBanNganh_TruongCongDanModelImpl._originalIDQLKT_DanhMucSoBanNganh = danhMucSoBanNganh_TruongCongDanModelImpl._IDQLKT_DanhMucSoBanNganh;

        danhMucSoBanNganh_TruongCongDanModelImpl._setOriginalIDQLKT_DanhMucSoBanNganh = false;

        danhMucSoBanNganh_TruongCongDanModelImpl._columnBitmask = 0;
    }

    @Override
    public CacheModel<DanhMucSoBanNganh_TruongCongDan> toCacheModel() {
        DanhMucSoBanNganh_TruongCongDanCacheModel danhMucSoBanNganh_TruongCongDanCacheModel =
            new DanhMucSoBanNganh_TruongCongDanCacheModel();

        danhMucSoBanNganh_TruongCongDanCacheModel.IDDanhMucSoBanNganh_TruongCongDan = getIDDanhMucSoBanNganh_TruongCongDan();

        danhMucSoBanNganh_TruongCongDanCacheModel.groupId = getGroupId();

        danhMucSoBanNganh_TruongCongDanCacheModel.companyId = getCompanyId();

        danhMucSoBanNganh_TruongCongDanCacheModel.userId = getUserId();

        danhMucSoBanNganh_TruongCongDanCacheModel.userName = getUserName();

        String userName = danhMucSoBanNganh_TruongCongDanCacheModel.userName;

        if ((userName != null) && (userName.length() == 0)) {
            danhMucSoBanNganh_TruongCongDanCacheModel.userName = null;
        }

        Date createDate = getCreateDate();

        if (createDate != null) {
            danhMucSoBanNganh_TruongCongDanCacheModel.createDate = createDate.getTime();
        } else {
            danhMucSoBanNganh_TruongCongDanCacheModel.createDate = Long.MIN_VALUE;
        }

        Date modifiedDate = getModifiedDate();

        if (modifiedDate != null) {
            danhMucSoBanNganh_TruongCongDanCacheModel.modifiedDate = modifiedDate.getTime();
        } else {
            danhMucSoBanNganh_TruongCongDanCacheModel.modifiedDate = Long.MIN_VALUE;
        }

        danhMucSoBanNganh_TruongCongDanCacheModel.IDQLKT_DanhMucSoBanNganh = getIDQLKT_DanhMucSoBanNganh();

        danhMucSoBanNganh_TruongCongDanCacheModel.IDDMDC_TruongCongDan = getIDDMDC_TruongCongDan();

        return danhMucSoBanNganh_TruongCongDanCacheModel;
    }

    @Override
    public String toString() {
        StringBundler sb = new StringBundler(19);

        sb.append("{IDDanhMucSoBanNganh_TruongCongDan=");
        sb.append(getIDDanhMucSoBanNganh_TruongCongDan());
        sb.append(", groupId=");
        sb.append(getGroupId());
        sb.append(", companyId=");
        sb.append(getCompanyId());
        sb.append(", userId=");
        sb.append(getUserId());
        sb.append(", userName=");
        sb.append(getUserName());
        sb.append(", createDate=");
        sb.append(getCreateDate());
        sb.append(", modifiedDate=");
        sb.append(getModifiedDate());
        sb.append(", IDQLKT_DanhMucSoBanNganh=");
        sb.append(getIDQLKT_DanhMucSoBanNganh());
        sb.append(", IDDMDC_TruongCongDan=");
        sb.append(getIDDMDC_TruongCongDan());
        sb.append("}");

        return sb.toString();
    }

    @Override
    public String toXmlString() {
        StringBundler sb = new StringBundler(31);

        sb.append("<model><model-name>");
        sb.append("qldc.pm.qlktcsdldc.model.DanhMucSoBanNganh_TruongCongDan");
        sb.append("</model-name>");

        sb.append(
            "<column><column-name>IDDanhMucSoBanNganh_TruongCongDan</column-name><column-value><![CDATA[");
        sb.append(getIDDanhMucSoBanNganh_TruongCongDan());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>groupId</column-name><column-value><![CDATA[");
        sb.append(getGroupId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>companyId</column-name><column-value><![CDATA[");
        sb.append(getCompanyId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>userId</column-name><column-value><![CDATA[");
        sb.append(getUserId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>userName</column-name><column-value><![CDATA[");
        sb.append(getUserName());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>createDate</column-name><column-value><![CDATA[");
        sb.append(getCreateDate());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
        sb.append(getModifiedDate());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>IDQLKT_DanhMucSoBanNganh</column-name><column-value><![CDATA[");
        sb.append(getIDQLKT_DanhMucSoBanNganh());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>IDDMDC_TruongCongDan</column-name><column-value><![CDATA[");
        sb.append(getIDDMDC_TruongCongDan());
        sb.append("]]></column-value></column>");

        sb.append("</model>");

        return sb.toString();
    }
}
